﻿<UserControl x:Class="UserManagementSettingsControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:Metro="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
             mc:Ignorable="d" 
             d:DesignHeight="500" d:DesignWidth="800" DataContextChanged="UserControl_DataContextChanged_1">
    <StackPanel>
        <Label Content="{DynamicResource Header}" FontSize="{DynamicResource HeaderFontSize}" FontFamily="{DynamicResource HeaderFontFamily}" Margin="6,0,0,0" Height="65" VerticalAlignment="Top" />
        <TabControl>
            <TabItem Header="{DynamicResource UserOverview}">
                <StackPanel>
                    <ListView ItemsSource="{Binding UserList}" MinHeight="150" Margin="15,15,15,0" Name="userlistview">
                        <ListView.ItemContainerStyle>
                            <Style TargetType="ListViewItem">
                                <Setter Property="Control.HorizontalContentAlignment" Value="Center" />
                                <Setter Property="FrameworkElement.MinHeight" Value="20px" />
                            </Style>
                        </ListView.ItemContainerStyle>
                        <ListView.View>
                            <GridView>
                                <GridViewColumn DisplayMemberBinding="{Binding Name}" Header="{DynamicResource UserName}" Width="150"/>
                                <GridViewColumn DisplayMemberBinding="{Binding ID}" Header="{DynamicResource UserID}" Width="100"/>
                            </GridView>
                        </ListView.View>
                    </ListView>
                    <GroupBox Margin="15,5,15,0" IsEnabled="{Binding EditAllowed, FallbackValue=False}" FontSize="12" Header="{DynamicResource WriteAccess}">
                        <StackPanel Orientation="Horizontal" Margin="0,0,0,5">
                            <CheckBox Content="{DynamicResource Order}" FontSize="12" IsChecked="{Binding ElementName=userlistview, Path=SelectedItem.CanWriteOrder}"/>
                            <CheckBox Content="{DynamicResource Article}" FontSize="12" Margin="20,0,0,0" IsChecked="{Binding ElementName=userlistview, Path=SelectedItem.CanWriteArticle}"/>
                            <CheckBox Content="{DynamicResource Customer}" FontSize="12" Margin="20,0,0,0" IsChecked="{Binding ElementName=userlistview, Path=SelectedItem.CanWriteCustomer}"/>
                        </StackPanel>
                    </GroupBox>
                    <GroupBox Margin="15,5,15,0" IsEnabled="{Binding EditAllowed, FallbackValue=False}" FontSize="12" Header="{DynamicResource ReadAccess}">
                        <StackPanel Orientation="Horizontal" Margin="0,0,0,5">
                            <CheckBox Content="{DynamicResource Order}" FontSize="12" IsChecked="{Binding ElementName=userlistview, Path=SelectedItem.CanReadOrder}"/>
                            <CheckBox Content="{DynamicResource Article}" FontSize="12" Margin="20,0,0,0" IsChecked="{Binding ElementName=userlistview, Path=SelectedItem.CanReadArticle}"/>
                            <CheckBox Content="{DynamicResource Customer}" FontSize="12" Margin="20,0,0,0" IsChecked="{Binding ElementName=userlistview, Path=SelectedItem.CanReadCustomer}"/>
                        </StackPanel>
                    </GroupBox>
                    <GroupBox Margin="15,5,15,0" IsEnabled="{Binding EditAllowed, FallbackValue=False}" FontSize="12" Header="{DynamicResource Others}">
                        <StackPanel Orientation="Horizontal" Margin="0,0,0,5">
                            <CheckBox Content="{DynamicResource CanEditUsers}" FontSize="12" IsChecked="{Binding ElementName=userlistview, Path=SelectedItem.CanEditUsers}"/>
                        </StackPanel>
                    </GroupBox>
                </StackPanel>
            </TabItem>
            <TabItem Header="{DynamicResource CreateUser}" Name="UserCreationTab" Visibility="Collapsed" >
                <StackPanel>
                    <GroupBox Margin="15,5,15,0" FontSize="12" Header="{DynamicResource Properties}">
                        <StackPanel>
                            <StackPanel Orientation="Horizontal" Margin="0,0,0,0">
                                <Label Content="{DynamicResource UserName}" Width="100"/>
                                <TextBox Width="200" Name="UserNameTB" Text="{Binding Name}"/>
                            </StackPanel>
                            <StackPanel Orientation="Horizontal" Margin="0,5,0,0">
                                <Label Content="{DynamicResource ID}" Width="100"/>
                                <TextBox Width="200" Name="UserIDTB" Text="{Binding ID}"/>
                            </StackPanel>
                            <StackPanel Orientation="Horizontal" Margin="0,5,0,5">
                                <Label Content="{DynamicResource Password}" Width="100"/>
                                <PasswordBox Width="200" Name="PasswordBox"/>
                            </StackPanel>
                        </StackPanel>
                    </GroupBox>
                    <GroupBox Margin="15,5,15,0" FontSize="12" Header="{DynamicResource WriteAccess}">
                        <StackPanel Orientation="Horizontal" Margin="0,0,0,5">
                            <CheckBox Content="{DynamicResource Order}" FontSize="12" IsChecked="{Binding CanWriteOrder}" Name="cb1"/>
                            <CheckBox Content="{DynamicResource Article}" FontSize="12" Margin="20,0,0,0" IsChecked="{Binding CanWriteArticle}"/>
                            <CheckBox Content="{DynamicResource Customer}" FontSize="12" Margin="20,0,0,0" IsChecked="{Binding CanWriteCustomer}"/>
                        </StackPanel>
                    </GroupBox>
                    <GroupBox Margin="15,5,15,0" FontSize="12" Header="{DynamicResource ReadAccess}">
                        <StackPanel Orientation="Horizontal" Margin="0,0,0,5">
                            <CheckBox Content="{DynamicResource Order}" FontSize="12" IsChecked="{Binding CanReadOrder}"/>
                            <CheckBox Content="{DynamicResource Article}" FontSize="12" Margin="20,0,0,0" IsChecked="{Binding CanReadArticle}"/>
                            <CheckBox Content="{DynamicResource Customer}" FontSize="12" Margin="20,0,0,0" IsChecked="{Binding CanReadCustomer}"/>
                        </StackPanel>
                    </GroupBox>
                    <GroupBox Margin="15,5,15,0" FontSize="12" Header="{DynamicResource Others}">
                        <StackPanel Orientation="Horizontal" Margin="0,0,0,5">
                            <CheckBox Content="{DynamicResource CanEditUsers}" FontSize="12" IsChecked="{Binding CanEditUsers}"/>
                        </StackPanel>
                    </GroupBox>
                    <Label Content="{DynamicResource SaveFailed}" Foreground="Red" Margin="15,5,0,0" Visibility="Collapsed" Name="SaveFailedLbl"/>
                    <Button Content="{DynamicResource Save}" Width="100" Margin="15,5,0,0" HorizontalAlignment="Left" Click="Button_Click_1"/>
                </StackPanel>
            </TabItem>
        </TabControl>
    </StackPanel>
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="./de.xaml" />
                <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colours.xaml" />
                <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
                <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
                <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.AnimatedSingleRowTabControl.xaml" />
                <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Blue.xaml" />
                <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>
</UserControl>
